package com.cosc716.simulator;

/**
 * @author davidmessing
 *
 */
public class Simulator {
	
	private final int SIM_TIME_INTERVALS = 360;
	private int SIM_STEP_SIZE = 10;
	
	private SimulationContext context;

	/**
	 * 
	 */
	public Simulator() {
		
		// Create a new SimulationContext
		this.context = new SimulationContext();
		
		// Create a DataSource and add it to the SimulationContext
		DataSource foo = new DataSourceFIFO();
		this.context.setDatasource(foo);
		
		// Create Commands and add them to the SimulationContext
		RunLoopCommand command;
		
		command = new CommandQueuePatrons(foo);
		this.context.addCommand(command);
		
		command = new CommandSeatPatrons(foo);
		this.context.addCommand(command);
		
		command = new CommandQueueOrders(foo);
		this.context.addCommand(command);
		
		command = new CommandDeliverOrders(foo);
		this.context.addCommand(command);
		
		command = new CommandRemovePatrons(foo);
		this.context.addCommand(command);
		
		// set the number simulation time intervals
		this.context.setTimeIntervals(SIM_TIME_INTERVALS);
	}
	
	public SimulationContext getContext() {
		return context;
	}

	public void simulate() {
		this.context.run();
	}
	
	public void step() {
		this.context.run(SIM_STEP_SIZE);
	}
}
